package com.qidian.mes.pro.controller;
import com.qidian.mes.pojo.WorkTicket;
import com.qidian.mes.pro.service.WorkTicketService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author chenzheng
 * @Company 起点编程
 * @Time 2023/10/26 16:15
 * @Description
 */
@RestController
@RequestMapping("/workorder")
@CrossOrigin
public class WorkTicketController {
    //注意WorkTicket中的id为workorderId
    @Autowired
    private WorkTicketService workTicketService;
   //工单列表查询
    @GetMapping("/get")
    public MESResult get(Long workorderId){
        return workTicketService.queryById(workorderId);
    }
    //新增工单列表
    @PostMapping("/save")
    public MESResult save(@RequestBody WorkTicket workTicket){
        return workTicketService.save(workTicket);
    }
    //编辑工单列表
    @PutMapping("/update")
    public MESResult update(@RequestBody WorkTicket workTicket){
        return workTicketService.update(workTicket);
    }
    //删除生产工单
    @PostMapping("/delete")
    public MESResult delete(Long workorderId){
        return workTicketService.delete(workorderId);
    }
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, WorkTicket workTicket){
        System.out.println(workTicket);
        return workTicketService.list(page,limit,workTicket);
    }
}
